package zeus.ejb;

import javax.ejb.EJB;
import javax.ejb.Stateful;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import zeus.model.Reserva;
import zeus.service.EjbQuartoService;
import zeus.service.EjbReservaService;

@Stateful
public class EjbReserva implements EjbReservaService{
	
	@PersistenceContext
	EntityManager entityManager;
	
	@EJB
	EjbQuartoService quartoService;
	
	//private Quarto quartoLivre;
	
	/**
	 * Construtor Padr�o
	 */
	public EjbReserva(){
		
	}
	
	public void salvarReserva(Reserva reserva){
		entityManager.persist(reserva);
	}
	
	
	
/*	@SuppressWarnings("unchecked")
	public List<Reserva> buscarReservas(){
		List<Reserva> reservas = new ArrayList<Reserva>();
		reservas = (ArrayList<Reserva>) entityManager.createQuery("from Reserva e").
				getResultList();
		
		return reservas;
	}

	@Override
	public boolean checharReservas(List<Quarto> quartos) {
		if(quartos.size() == 0){
			return false;
		}
		
		for(Quarto q : quartos){
			if(q.getStatusQuarto().equals(StatusQuarto.LIVRE)){
				this.quartoLivre = q;
				return true;
			}
		}
		
		return false;
	}

	@Override
	public Quarto retornarQuartoLivre() {
		return this.quartoLivre;
	}*/

}
